Skip to content

Change SumoBot to deleted_user #6537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

smithellis
Copy link
Contributor

@smithellis smithellis commented Mar 4, 2025

SumoBot isn't a meaningful name in the messaging system for a user who is deleted, and could cause confusion.

  • Messages from or to a deleted user will now be from or to deleted user.

mozilla/sumo#2225

@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch 2 times, most recently from 86ee65a to dd86833 Compare March 5, 2025 15:31
@smithellis smithellis requested a review from Copilot March 5, 2025 15:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR aims to change the display name for a deleted user from "SumoBot" to "deleted user" in the messaging system to avoid confusion. The key changes include adding an "is_bot_user" flag in the view context and updating the helper function _add_recipients to include the flag for recipients.

Reviewed Changes

File Description
kitsune/messages/views.py Updated view context and helper function to add is_bot_user flag

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch from 9ed6fcb to 24c1360 Compare March 6, 2025 18:31
@smithellis
Copy link
Contributor Author

I moved the logic to the view, and appended is_bot_user to each user to designate the bot user(s).

@smithellis smithellis requested a review from akatsoulas March 6, 2025 18:35
@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch from 24c1360 to ed43cee Compare March 6, 2025 19:28
@smithellis smithellis requested a review from Copilot March 10, 2025 19:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR updates the messaging views to mark messages from a deleted user by flagging them as a bot user.

  • Updated the inbox and read views to set an is_bot_user flag for senders matching the SumoBot username.
  • Modified the read-outbox view and _add_recipients helper to assign the is_bot_user flag for recipients.

Reviewed Changes

File Description
kitsune/messages/views.py Added logic in multiple views to flag users as bot users based on their username, supporting the change of SumoBot to deleted user in the messaging system.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

kitsune/messages/views.py:35

  • [nitpick] The attribute 'is_bot_user' is used to determine if a message is from a deleted user, which can be ambiguous. Consider renaming it to 'is_deleted_user' for clarity in the context of the PR.
message.sender.is_bot_user = message.sender.username == settings.SUMO_BOT_USERNAME

kitsune/messages/views.py:50

  • [nitpick] Using the 'is_bot_user' designation here may be confusing given the PR's intent to represent deleted users. It may be clearer to use 'is_deleted_user' consistently.
if message.sender.username == settings.SUMO_BOT_USERNAME:

kitsune/messages/views.py:74

  • [nitpick] The naming 'is_bot_user' might be misleading in the context of marking deleted users. Consider renaming it to 'is_deleted_user' for consistency across the application.
user.is_bot_user = user.username == settings.SUMO_BOT_USERNAME

kitsune/messages/views.py:229

  • [nitpick] Since this flag is ultimately meant to represent a deleted user, renaming 'is_bot_user' to 'is_deleted_user' would improve clarity in the codebase.
msg.recipient.is_bot_user = msg.recipient.username == settings.SUMO_BOT_USERNAME

@smithellis smithellis requested a review from escattone March 11, 2025 18:56
@akatsoulas
Copy link
Collaborator

@smithellis with the #6559 merged, this needs an update

@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch from ed43cee to 48fe64a Compare March 18, 2025 20:51
@smithellis smithellis marked this pull request as draft March 19, 2025 12:05
@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch 4 times, most recently from 2d3a117 to 9e94a68 Compare March 19, 2025 20:12
@smithellis smithellis marked this pull request as ready for review March 19, 2025 20:14
* In messaging, when a user who received a message is deleted
the sending users outbox will now show the message was to
deleted user
* When a message in your inbox is from a user who is deleted
it will appear as being from deleted user
@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch from 9e94a68 to c981b19 Compare March 19, 2025 20:34
Copy link
Collaborator

@akatsoulas akatsoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost done. Extracting the check to a method/filter/function and removing the addition of sumobot to the group should do it. Let me know when it's ready for a final pass

outbox_messages = OutboxMessage.objects.filter(to=user)
for message in outbox_messages:
message.to.remove(user)
message.to.add(sumo_bot)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of assigning these messages to SuMoBot? Good clean up work on removing the user from the recipient list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If userA sent a message to userB and userB gets deleted, the message in userA's Outbox needs to have a 'To' person - thus the reassignment.

@smithellis smithellis force-pushed the change-sumobot-name-in-messages branch from a62ee82 to 7d5597c Compare March 20, 2025 13:37
Copy link
Collaborator

@akatsoulas akatsoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Please squash into a single commit before merging

@smithellis smithellis merged commit 3762500 into mozilla:main Mar 20, 2025
2 checks passed
@smithellis smithellis deleted the change-sumobot-name-in-messages branch March 20, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants